Cytosim  PI
Cytoskeleton Simulator
Parser Class Reference

Detailed Description

This is where the syntax of the config file is defined

Inheritance diagram for Parser:
Interface SimThread

Public Member Functions

 Parser (Simul &s, bool allow_set, bool allow_change, bool allow_new, bool allow_run, bool allow_write)
 set the permission of the parser More...
 
virtual ~Parser ()
 destructor
 
void parse_set (std::istream &)
 parse command set More...
 
void parse_change (std::istream &)
 parse command change More...
 
void parse_new (std::istream &)
 parse command new More...
 
void parse_delete (std::istream &)
 parse command delete More...
 
void parse_mark (std::istream &)
 parse command mark More...
 
void parse_cut (std::istream &)
 parse command cut More...
 
void parse_run (std::istream &)
 parse command run More...
 
void parse_include (std::istream &)
 parse command include More...
 
void parse_read (std::istream &)
 parse command read More...
 
void parse_write (std::istream &)
 parse command write More...
 
void parse_call (std::istream &)
 parse command call More...
 
void parse_repeat (std::istream &)
 parse command repeat More...
 
void parse_stop (std::istream &)
 parse command stop More...
 
void parse (std::istream &, std::string const &file_name)
 Parse a std::istream. More...
 
void readConfig (std::string const &name)
 Open and parse the config file with the given name.
 
void readConfig ()
 Parse the default config file (SimulProp::config)
 
void readProperties ()
 Parse the default output property file (SimulProp::property_file)
 
- Public Member Functions inherited from Interface
 Interface (Simul &s)
 associates with given Simul
 
virtual ~Interface ()
 destructor
 
virtual void hold ()
 this is called between commands during the execution process More...
 
Propertyexecute_set (std::string const &k, std::string const &n, Glossary &)
 create a new Property of kind k from options set in Glossary More...
 
void execute_change (Property *, Glossary &)
 change values in Property according to Glossary
 
Propertyexecute_change (std::string const &k, std::string const &n, Glossary &)
 change values in Property of kind k following options set in Glossary
 
void change_display (std::string const &k, std::string const &n, Glossary &)
 change 'display' (and only this) in corresponding Property More...
 
ObjectList execute_new (std::string const &k, std::string const &n, Glossary &)
 create 1 Object of kind k with name n, following options in Glossary More...
 
int execute_new (std::string const &k, std::string const &n, unsigned cnt)
 create 'cnt' objects of kind k with name n, randomly placed in space (no option)
 
void execute_delete (std::string const &k, std::string const &n, Glossary &, int cnt)
 delete cnt objects of kind k with name n, following options in Glossary More...
 
void execute_mark (std::string const &k, std::string const &n, Glossary &, int cnt)
 mark cnt objects of kind k with name n, following options in Glossary More...
 
void execute_cut (std::string const &k, std::string const &n, Glossary &)
 cut fibers, following different options in Glossary
 
void execute_read (std::string const &file, unsigned index)
 import objects from another file More...
 
void execute_write (std::string &file, std::string const &what, Glossary &)
 write output file with object coordinates or information on objects More...
 
void execute_run (Glossary &opt, unsigned cnt, bool do_write)
 perform simulation steps
 

Additional Inherited Members

- Protected Attributes inherited from Interface
Simulsimul
 associated Simul
 

Constructor & Destructor Documentation

Parser ( Simul s,
bool  ds,
bool  dc,
bool  dn,
bool  dr,
bool  dw 
)

The permission of the parser are:

  • allow_change: existing Property or Object can be modified
  • allow_set: new Properties can be created
  • allow_new: new Object can be created
  • allow_write: can write to disc

Member Function Documentation

void parse ( std::istream &  is,
std::string const &  msg 
)
virtual

The configuration file should contain a succession of commands. Most command have the following syntax:

COMMAND CLASS NAME
{
PARAMETERS
}

Essential commands:

Command Action
set Create a new Property, and set parameter values
change Change parameter values in an existing Property
new Create one or many new objects
delete Delete objects
run Perform simulation steps
read Read another config file
write export formatted data with selected object properties
import Import Objects from trajectory file
export Export all Objects to file, with their coordinates

Other commands:

Command Action
mark Mark objects
repeat Execute code a number of times
stop Stop program
cut Cut Fibers
call Call a custom function

Implements Interface.

void parse_call ( std::istream &  is)

Call custom function

call FUNCTION_NAME

FUNCTION_NAME should be custom?, where ? is a digit.

Todo:
: propagate the arguments (do_set, do_new) to the custom commands
void parse_change ( std::istream &  is)

Change the value of one (or more) parameters for property NAME of class CLASS.

change CLASS NAME
{
PARAMETER = VALUE
...
}

Short syntax:

change CLASS:PARAMETER NAME VALUE

The possible values of CLASS are in the List of objects.
The NAME should have been defined previously in the same class with set, but it is possible to use a star (*) to change all properties of the class.

void parse_cut ( std::istream &  is)

Cut all fibers that intersect a given plane.

cut fiber NAME
{
plane = VECTOR, REAL
}

NAME can be '*' to cut all fibers. The plane is specified by a normal vector n (VECTOR) and a scalar (REAL). The plane is defined by n.x + a = 0

void parse_delete ( std::istream &  is)

Delete objects:

delete [MULTIPLICITY] CLASS NAME
{
mark = INTEGER
position = POSITION
}

NAME can be '*', and the parameters mark and position are optional.

To delete all objects of the class:

delete CLASS *

To delete all objects of specified NAME:

delete CLASS NAME

To delete at most CNT objects of class NAME:

delete CNT CLASS NAME

To delete all objects with a specified mark:

delete CLASS *
{
mark = INTEGER
}

To delete all objects within a Space:

delete CLASS *
{
position = inside, SPACE
}

The SPACE must be the name of an existing Space. Only 'inside' and 'outside' are valid specifications.

void parse_include ( std::istream &  is)

Include another specified config file, and executes it.

include FILE_NAME
{
required = BOOL
}

By default, required = 1, and execution will terminate if the file is not found. If required is set to 0, the file will be read, but execution will continue even if the file is not found.

Todo:
: able to specify do_set and do_new for command 'include'
void parse_mark ( std::istream &  is)

Mark objects:

mark [MULTIPLICITY] CLASS NAME
{
mark = INTEGER
position = POSITION
}

NAME can be '*', and the parameter position is optional. The syntax is the same as for command delete.

void parse_new ( std::istream &  is)

The command new creates one or more objects with given specifications:

new [MULTIPLICITY] CLASS NAME
{
position = POSITION
orientation = ROTATION
post_translation = VECTOR
post_rotation = ROTATION
mark = INTEGER
required = INTEGER
}

The possible values of CLASS are in the List of objects.
The NAME should have been defined previously in the same class with set.
The other parameters are:

Parameter type Description
MULTIPLICITY INTEGER the number of objects, by default 1.
orientation ROTATION a rotation applied before translation
position POSITION a translation
post_translation VECTOR a translation applied every time after one object is created
post_rotation ROTATION a rotation applied every time after one object is created
mark INTEGER this mark is given to all objects created (default = 0).
required INTEGER cytosim will stop if it cannot create as many objects as specified (default=0)

Note that position only applies to movable objects, and orientation only applies to rotatable objects. In addition, post_translation and post_rotation are relevant only if (MULTIPLICITY > 1), and do not apply to the first object.

Short syntax:

new [MULTIPLICITY] CLASS NAME ( POSITION )

Shorter syntax:

new [MULTIPLICITY] CLASS NAME
void parse_read ( std::istream &  is)

Import Objects from a frame of the specified trajectory file.

read [INTEGER] FILE_NAME

by default frame = 0, corresponding to the first frame in the file.

Note that the simulation time will be changed to match the one stored in the file, but it can be reset with:

change simul * { time=0 }
void parse_repeat ( std::istream &  is)

Repeat specified code.

repeat INTEGER { CODE }
void parse_run ( std::istream &  is)

Perform simulation steps, and write frames to files. Currently, only 'run simul *' is supported.

run [NB_STEPS] simul *
{
nb_steps = INTEGER
solve = SOLVE_MODE
event = RATE, ( CODE )
nb_frames = INTEGER
prune = BOOL
}

The optional specification [NB_STEPS] enables the short syntax:

run NB_STEPS simul *
Option Default Action
nb_steps 1 number of simulation steps
solve 1 Enable/disable motion of the objects
event none custom code executed stochastically with prescribed rate
nb_frames 0 number of states written to trajectory file
prune true Print only parameters that are different from default


If set, event defines an event occuring at a rate specified by the positive real RATE. The action is defined by CODE, a string enclosed with parenthesis containing cytosim commands. This code will be executed at stochastic times with the specified rate.

Example:

event = 10, ( new fiber actin { position=(rectangle 1 6); length=0.1; } )

Calling run will not output the initial state, but this can be done with write:

write state objects.cmo { append = 0 }
run 1000 simul *
{
nb_frames = 10
}
Todo:
: add code executed at each time-step
void parse_set ( std::istream &  is)

Create a new Property (a set of parameters associated with a class).

set CLASS NAME
{
PARAMETER = VALUE
...
}

Short syntax:

set CLASS:PARAMETER NAME VALUE

CLASS should be one of the predefined object (see List of objects).
NAME can be any string, but it should start with a letter.
The command will define the given NAME for this class.

void parse_stop ( std::istream &  is)

Terminates execution

stop
void parse_write ( std::istream &  is)

Export to file. The general syntax is:

write WHAT FILE_NAME
{
append = BOOL
binary = BOOL
}

WHAT can be state or a valid argument to report:

If * is specified instead of a file name, the current trajectory file will be used if WHAT=statee, or the standard output for a report.

The binary option only applies if WHAT=state. By default:

  • append = true
  • binary = true

Short syntax:

write WHAT FILE_NAME

Examples:

write state objects1.cmo { append=0 }
write state objects1.txt { binary=0 }
write properties properties1.cmo { append=0 }
write fiber:length fibers.txt

Attention: For safety reason, this command is disabled for play.